import inquirer from 'inquirer'
import { chenFaMod, addMod } from './questions.js'
const opts = [
    {
        type: 'input', name: 'type', message: '请输入你想使用的算法:'
    }
]
function getFunction(type) {
 if (type === '*') return chenFaMod;
 if (type === '+') return addMod;
 return undefined;
}
inquirer.prompt(opts).then(ans => {
    const mod = getFunction(ans.type)
    if (!mod) return console.log('请输入合法参数');
    inquirer.prompt(mod.opts).then((answers) => {
        const res = mod.use(answers)
        console.log(`计算结果为：${res}`);
    })
})
